<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Web Component</title>
</head>

<body>
    <my-card src="./top2.svg" />
    <script type="module">
        class UserCard extends HTMLElement {
            constructor() {
                super();
                this.createElement();
            }

            createElement() {
                const shadow = this.attachShadow({
                    mode: "open"
                });
                const image = document.createElement('img');
                image.src = this.getAttribute('src');
                shadow.appendChild(image);
            }
        }
        window.customElements.define('my-card', UserCard);
    </script>
</body>

</html>